#include "askdialog.h"
#include "ui_askdialog.h"

AskDialog::AskDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::AskDialog)
{
    ui->setupUi(this);
}

AskDialog::~AskDialog()
{
    delete ui;
}

bool AskDialog::GetUserClick(QWidget *parent, const QString &title, const QString &message)
{
    auto dialog = GetInstance(parent);
    dialog->setWindowTitle(title);
    dialog->ui->text->setText(message);
    return (dialog->exec() == QDialog::Accepted);
}

AskDialog* AskDialog::GetInstance(QWidget *parent){
    static AskDialog* m_instance = nullptr;
    if(!m_instance){
        m_instance = new AskDialog(parent);
    }
    return m_instance;
}



void AskDialog::on_ok_clicked()
{
    this->accept();
}


void AskDialog::on_cancel_clicked()
{
    this->reject();
}

